<?php

use yii\helpers\Html;
use yii\grid\GridView;
use backend\models\UserGroup;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\UserSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = Yii::t('app', 'Users');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="user-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <?= Html::a(Yii::t('app', 'Create User'), ['create'], ['class' => 'btn btn-success']) ?>
    </p>
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],

            'id',
            'oppenid',
            'subscribe',
            'nickname',
            [
                'attribute'=>'sex',
                'value'=>function($data){
                    return $data->sex==1?'男':'女';
                }
            ],
            //'sex',
            'city',
            'country',
            'province',
            //'headimgurl:image',
            // 'subscribe_time:datetime',
            // 'remark',
            [
                'attribute'=>'groupid',
                'filter'=> UserGroup::find()->getAllByArray(),
                'value'=>function($data){
                    return UserGroup::find()->getNameById($data->groupid); 
                }
            ],
            // 'unionid',

            ['class' => 'yii\grid\ActionColumn'],
        ],
    ]); ?>
</div>
